package com.lablzh.gdxy.repository.assistant;

import com.lablzh.gdxy.entity.assistant.AssistantApply;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

public interface AssistantApplyRepository extends JpaRepository<AssistantApply,Integer> {
    AssistantApply findByStudentUsernameAndProjectID(String username, Integer id);

    List<AssistantApply> findAllByTeacher(String username);

    List<AssistantApply> findAllByStudentUsername(String username);

    List<AssistantApply> findAllByProjectID(Integer id);
    @Modifying
    @Transactional
    @Query("update AssistantApply set status=?2 where id=?1")
    int  updateStatusById(Integer id,String status);

    List<AssistantApply> findAllByProjectIDAndStatus(Integer id, String status);

    @Transactional
    void deleteByProjectID(Integer id);

}


